<template>
  <a-drawer v-model:visible="visible" title="标签管理详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="标签名称">{{ dataDetail?.name }}</a-descriptions-item>
      <a-descriptions-item label="分类ID">{{ dataDetail?.categoryId }}</a-descriptions-item>
      <a-descriptions-item label="状态(1:启用 0:禁用)">{{ dataDetail?.status }}</a-descriptions-item>
      <a-descriptions-item label="删除标识">{{ dataDetail?.deleted }}</a-descriptions-item>
      <a-descriptions-item label="">{{ dataDetail?.createTime }}</a-descriptions-item>
      <a-descriptions-item label="">{{ dataDetail?.updateTime }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'
import { type TagDetailResp, getTag as getDetail } from '@/apis/admin/tag'

const { width } = useWindowSize()

const dataId = ref('')
const dataDetail = ref<TagDetailResp>()
const visible = ref(false)

// 查询详情
const getDataDetail = async () => {
  const { data } = await getDetail(dataId.value)
  dataDetail.value = data
}

// 打开
const onOpen = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onOpen })
</script>

<style scoped lang="scss"></style>
